<?php
if (!isset($_SERVER['argc'], $_SERVER['argv']) || PHP_SAPI != 'cli'
	|| !empty($_REQUEST)) {
	exit;
}
define('DEBUG', 'on');
//必须设置此目录,PHP程序的根目录
define('WEBPATH', __DIR__);
define('WEBROOT', 'http://mytest.com');

require '/data/www/wwwroot/composer/vendor/autoload.php';

//包含框架入口文件
require __DIR__ . '/libs/lib_config.php';
//开发环境的配置，如果此目录有配置文件，会优先选择
Swoole::$php->config->setPath(WEBPATH . '/apps/configs/dev/');
//Swoole::$php->runMVC();
function command($argv)
{
	array_shift($argv);
	$ctrlName = array_shift($argv);
	$method = array_shift($argv);

	$classFile = WEBPATH . '/cron/commands/' . $ctrlName . '.php';
	require_once $classFile;

	$className = basename($ctrlName);
	$ctrl = new $className(\Swoole::getInstance());

	return $ctrl->$method($argv);
}

exit(command($_SERVER['argv']));
